<template>
	<section>
		<!--start  面包屑-->
		<div class="location">
			<el-breadcrumb separator="/">
				<el-breadcrumb-item :to="{path:'/index'}">首页</el-breadcrumb-item>
				<el-breadcrumb-item :to="{path:'/order'}">订单</el-breadcrumb-item>
				<el-breadcrumb-item :to="{path:'/order'}">订单列表</el-breadcrumb-item>
				<el-breadcrumb-item>订单详情</el-breadcrumb-item>
			</el-breadcrumb>
			<help-components>
				<span slot="headText">{{helpData.templateName}}</span>
				<p slot="headDescText" v-html="helpData.templateRemark"></p>
				<div slot="helpContentWrap">
					<div v-for="(item,index) in helpData.questionAndAnswerArray">
						<h3>{{item.templateContent}}</h3>
						<p v-html="item.templateRemark"></p>
					</div>
				</div>
			</help-components>
		</div>
		<!--end  面包屑-->

		<div class="order" id="order">
			<!--发货-->
			<transition name="fade">
				<div class="add" v-if="add">
					<div class="">
						<div class="order-select">
							<h2>{{saleOrderViewVo.dataBillstateStr}}</h2>
							<p><span class="select-span">订单号：{{saleOrderViewVo.orderCode}}</span><span style="margin-left: 20px;">客户名称 : {{saleOrderViewVo.memberBname}}【{{saleOrderViewVo.gradeName}}】</span></p>
						</div>
						<br />
						<p>&nbsp;&nbsp;&nbsp;若确认已经发货，请填写发货信息：</p>
						<div class="">
							<div class="" style="width: 400px;float: left;">
								<template>
									<div class="Fblock">
										<span class="demonstration">发货日期</span>
										<el-date-picker v-model="Fdate" type="date" placeholder="选择日期" :default-value="Date()">
										</el-date-picker>
									</div>
								</template>
								<el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign">
									<el-form-item label="物流公司">
										<el-input v-model="formLabelAlign.region"></el-input>
									</el-form-item>
									<el-form-item label="物流单号">
										<el-input v-model="formLabelAlign.type"></el-input>
									</el-form-item>
								</el-form>
							</div>
							<div class="wuliB">
								<el-form ref="form" :model="form" label-width="150px">
									<el-form-item label="物流备注">
										<el-input type="textarea" v-model="form.desc"></el-input>
									</el-form-item>
								</el-form>
							</div>
						</div>
					</div>
					<div class="search-btn">
						<el-button @click="addDeliveryMessage()" type="primary">确定</el-button>
						<el-button @click="add=false">取消</el-button>
					</div>
				</div>
			</transition>
			<!---->
			<!--添加收款记录-->
			<transition name="fade">
				<div class="add" v-if="shoukuan">
					<div class="">

						<h3 style="margin-left: 25px;">添加收款记录</h3>
						<div class="daizhifu">
							<p><span class="select-span">订单号：{{saleOrderViewVo.orderCode}}<i v-if="saleOrderViewVo.orderApplySpecial == '1'" class="tejia">特价</i></span><span style="margin-left: 20px;">客户名称 : {{saleOrderViewVo.memberBname}}【{{saleOrderViewVo.gradeName}}】</span></p>
							<span>待支付:<span style="margin-left: 20px;">{{orderUnpaidMoney}}</span></span>
							<i><span>订单金额：{{orderTotalMoney.toFixed(2)}}</span><span>已付款:{{orderPaidMoney.toFixed(2)}}</span><span>待确认付款:{{orderConfirmMoney.toFixed(2)}}</span></i>

						</div>
						<h3 style="margin-left: 25px;margin-top: 20px;">使用资金账户付款</h3>
						<div class="" style="width: 400px;margin-top: 20px;float: left;">
							<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
								<el-form-item label="可用余额" prop="payMoneyOnline">
									<el-input v-model="ruleForm.payMoneyOnline"></el-input>
								</el-form-item>
							</el-form>

						</div>
						<span style="color: #888;margin-top: 30px;float: left;margin-left: 5px;">余额{{fundAvailMoney}}</span>
						<h3 style="margin-left: 25px;margin-top: 20px;clear: both;">客户已线下付款</h3>
						<div class="">
							<div class="" style="width: 400px;float: left;margin-top: 18px;">
								<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
									<el-form-item label="付款金额" prop="payMoneyOffline">
										<el-input v-model="ruleForm.payMoneyOffline"></el-input>
									</el-form-item>
									<el-form-item label="付款日期" required>
										<el-col :span="11">
											<el-form-item prop="merchantDate">
												<el-date-picker type="datetime" placeholder="选择日期" v-model="ruleForm.merchantDate" style="width: 100%;"></el-date-picker>
											</el-form-item>
										</el-col>

									</el-form-item>

									<el-form-item label="收款账号" prop="merchantSignNo">
										<el-select @change="vFun_changeMerchant" v-model="ruleForm.merchantCode" placeholder="请选择">

											<el-option v-for="(item,index) in fundMerchantViewVoList" :label="item.bankAndAccountStr" :value="item.merchantCode"></el-option>
										</el-select>
									</el-form-item>

								</el-form>
							</div>
							<div class="wuliB enclosure" style="margin-left: 50px;">
								<el-form ref="form" :model="form" label-width="100px">
									<el-form-item label="备注">
										<el-input type="textarea" v-model="ruleForm.remark"></el-input>
									</el-form-item>
								</el-form>
								<el-upload
				                    class="upload-demo fl"
				                    action="/v3/misc/common/uploadFile"
				                    :file-list="vue_upload_fileList"
				                    :data="vue_upload_uploadData"
				                    :on-remove="vFun_upload_remove"
				                    :on-success="vFun_upload_success"
				                    :on-error="vFun_upload_error"
				                    :before-upload="vFun_upload_before">
				                    <el-button style="margin-left:0;" class="fl" size="small" type="primary">点击上传</el-button>
				                    <div class="el-upload__tip fl" title="（建议上传订单付款凭证，如汇款单等；附件最大20M，支持格式：Word、Excel、Txt、JPG、PNG、BMP、GIF）">(建议上传订单付款凭证,如汇款单等;附件最大20M,支持格式:Word、Excel、Txt、JPG、PNG、BMP、GIF)</div>
				                </el-upload>



								<!--<el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/" :on-change="handleChange" :file-list="fileList3">
									<el-button size="small" type="primary">点击上传</el-button>
									<div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
								</el-upload>-->
							</div>
						</div>
					</div>
					<div class="search-btn">
						<el-button @click="shoukuanMethod" type="primary">确定</el-button>
						<el-button @click="shoukuan=false">取消</el-button>
					</div>
				</div>
			</transition>
			<!---->
			<div class="order-caozuo" v-if="activeName=='first'">
				<span @click="update" v-if="saleOrderViewVo.dataBillstate == '1'"><em class="iconfont"  style="top: 0px;">&#xe77d;</em>修改</span>
				<!--<span><em class="iconfont">&#xe644;</em>作废</span>
				<span><em class="iconfont">&#xe6bb;</em>打印</span>
				<span><em class="iconfont">&#xe631;</em>导出</span>-->
				<span @click="retreat" v-if="saleOrderViewVo.dataBillstate == '2' || saleOrderViewVo.dataBillstate == '3'"><em class="iconfont">&#xe631;</em>退回</span>
				<span @click="auditpass" class="outpass" v-if="saleOrderViewVo.dataBillstate == '1'">通过</span>
				<span @click="batchFinancepass" class="outpass" v-if="saleOrderViewVo.dataBillstate == '2'">通过</span>
				<span @click="activeName='second'" v-if="saleOrderViewVo.dataBillstate == '3'" class="outpass">出库</span>
				<span @click="activeName='second'" v-if="saleOrderViewVo.dataBillstate == '4'" class="outpass">发货</span>
			</div>
			<template>
				<el-tabs v-model="activeName" @tab-click="handleClick">
					<el-tab-pane label="订单详情" name="first">
						<c-order-detalis></c-order-detalis>
					</el-tab-pane>
					<el-tab-pane label="出库/发货记录" name="second">
						<c-delivery :deliveryState='vue_deliveryRes' @vue_fahuo='vFun_fahuo'></c-delivery>
					</el-tab-pane>
					<el-tab-pane label="收款记录" name="third">
						<c-gathering @vue_shoukuan_boolean='vFun_shoukuan_isShow'></c-gathering>
					</el-tab-pane>
				</el-tabs>
			</template>
		</div>
	</section>
</template>

<script>
	import helpComponents from '../../../components/help/help'
	import cDelivery from './component_delivery.vue'
	import cGathering from './component_gathering.vue'
	import cOrderDetalis from './component_orderDetalis.vue'
	export default {
		components: {
			helpComponents,
			cDelivery,
			cGathering,
			cOrderDetalis
		},
		data() {
			return {
				vue_deliveryRes:false,
				fundAvailMoney:0,  //账号余额
				vue_upload_fileList:[],  //上传附件的list
				vue_upload_uploadData:{  //附件上传的data
					fileName:'',  //附件文件名
					moduleName:'Sale',  //模块
					fromTable:'SaleOrder',  //来源表
					fromCode:''  //订单code
				},

				helpData: {
					templateName: "",
					templateRemark: "",
					questionAndAnswerArray: []
				},
				orderTotalMoney: 0,
				orderPaidMoney: 0,
				orderConfirmMoney: 0,
				orderUnpaidMoney: 0,

				tabxiang: false,
				orderTotalFreight: '0.00', // 运费
				memberBname: '', // 客户名称
				gradeName: '', // 客户级别
				orderCode: '', // 订单号
				orderApplySpecial: '1', // 是否特价
				caoRz: false, // 操作是否显示
				chkuAct: true, // 出库发货记录是否显示
				Fdate: '', // 发货日期
				saleOrderViewVo: {}, // 订单对象
				saleOrderGoodsViewVoList: [], // 订单商品集合
				saleOrderGoodsViewVoList2: [],
				fundMerchantViewVoList: [], //收款账号集合
				labelPosition: 'right',
				formLabelAlign: { // 物流信息
					region: '',
					type: ''
				},
				form: { // 物流备注
					desc: ''
				},
				todos: [], // 添加备注
				orderBuyRemark: '无', // 备注
				yema: 1, // 当前页码
				pageSize: 10, // 每页条数
				ruleForm: {
					merchantListMoney: '',
					region: '',
					merchantDate: '', //付款日期
					merchantSignNo: '', //收款账号
					merchantCode:'',//收款账号代码
					payMoneyOffline:0.00, //付款金额
				},
				rules: {
					name: [{
						required: true,
						message: '请输入金额',
						trigger: 'blur'
					}, ],
					date1: [{
						type: 'date',
						required: true,
						message: '请选择日期',
						trigger: 'change'
					}]
				},

				//上传附件
				fileList3: [{
					name: 'food.jpeg',
					url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
					status: 'finished'
				}, {
					name: 'food2.jpeg',
					url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
					status: 'finished'
				}],

				paixu: 3,

				activeName: 'first',
				invalue: 0, // 数量
				valuesum: 0, // 合计
				checked: false,
				disad: true,
				add: false,
				shoukuan: false, //显示添加收款记录
				fpneirong: '', // 发票内容
				putongfp2: false, // 普通发票
				zengzhifp: false, // 增值发票
				//选择客户

				value: '',

				//日期
				pickerOptions0: {
					disabledDate(time) {
						return time.getTime() < Date.now() - 8.64e7;
					}
				},
				deliveryDate: '', //交货日期
				//发票信息
				valu: '选项1',
				skTableData: [], //

			}
		},
		filters: {
			//时间格式转换
			dateFilterFn(val) {
				let time = new Date(val);
				let month = time.getMonth().length == "2" ? time.getMonth() : "0" + time.getMonth();
				let day = time.getDay().length == "2" ? time.getDay() : "0" + time.getDay();
				return time.getFullYear() + "-" + month + "-" + day;
			}
		},
		created(){
			this.vue_upload_uploadData.fromCode = localStorage.getItem("orderCode");
		},
		mounted() {
			this.activeName = localStorage.getItem("activeName");
			//获取窗口高度
			var winHieg = document.documentElement.clientHeight;
			var cont = document.getElementById("order");
			cont.style.height = winHieg - 105 + "px";

			//收款账号列表
			this.axios({
				method: 'post',
				url: "/v3/fund/merchants/listAll",
				data: {

				}
			}).then((res) => {
				this.fundMerchantViewVoList = res.data.list;
			}).catch((err) => {
				this.Public.openError(this, err.response.data);
			});

			/*订单收款统计跳转*/
			//			if(localStorage.getItem("activeName")!=undefined&&localStorage.getItem("activeName")!=null){

			//				localStorage.setItem("activeName","first");
			//			}
			//查询订单和当前资金账户详情
			this.queryOrderAndFud();
			this.queryByPage();
			this.query_checkout();
			//帮助功能
			this.query_systemTemplate();
		},
		methods: {
			vFun_upload_remove(file,fileList){  //附件上传的移除事件


	    	},
	    	vFun_upload_success(res,file,fileList){  //附件上传的成功事件
	    		this.Public.openSuccess(this,"操作成功！")

	    	},
	    	vFun_upload_error(err,file,fileList){  //附件上传的失败事件
	    		this.Public.openError(this,'上传失败，请重新上传！')
	    	},
	    	vFun_upload_before(file){  //附件上传的before事件
	    		this.vue_upload_uploadData.fileName=file.name; //获取上传时的fileName
	    		const typeArr = ['xls','xlsx','doc','docx','png','jpg','jpeg','txt','gif','bmp'];  //定义上传的类型
		        const isLt20M = file.size / 1024 / 1024 <= 20;  //判断文件大小
		    		let FileName = file.name.substr(file.name.lastIndexOf('.')+1);  //得到上传的类型

		        if (typeArr.indexOf(FileName)===-1) {  //判断类型
		        	this.Public.openError(this,"上传附件类型有误!")
		        }

		        if (!isLt20M) {  //判断大小
		        	this.Public.openError(this,"上传附件大小不能超过20MB!")
		        }
		        return (typeArr.indexOf(FileName)!==-1) && isLt20M;
	    	},
			vFun_shoukuan_isShow(data){  //监听收款记录组件的添加收款记录按钮
				this.shoukuan = data.shoukuan;
				this.ruleForm.merchantDate = data.dateNow;
			},
			vFun_fahuo(data){
				this.add = data.add;
			},
			vFun_changeMerchant(index){
				this.fundMerchantViewVoList.forEach(item=>{
					if(index===item.merchantCode){
						this.ruleForm.merchantSignNo=item.bankAndAccountStr;
					}
				})	
			},
			//-------------------财务审核----------------------------------------
			batchFinancepass() {
				this.$confirm('确定财务审核通过？', '确认', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					cancelButtonClass: "fr",
					confirmButtonClass: "fr",
				}).then(() => {
					this.axios({
						method: 'PATCH',
						url: "/v3/sale/orders/" + this.saleOrderViewVo.orderCode + "/batchFinancepass",
					}).then((res) => {
						this.queryByPage();
            			this.$router.push({path: "/order"});
						this.Public.openSuccess(this, "操作成功！");
					});
				}).catch((err) => {
					this.Public.openError(this, err.response.data);
				});
			},

			//----------------查询订单和当前资金账户详情----------------------
			queryOrderAndFud() {
				this.axios({
					method: 'POST',
					url: "/v3/sale/orders/" + localStorage.getItem("orderCode") + "/queryOrderAndFud",
					data: {},
				}).then((res) => {
					this.memberBname = res.data.memberBname; //客户名称
					this.orderCode = res.data.orderCode; //订单编号
					this.orderApplySpecial = res.data.orderApplySpecial; //是否 特价
					this.deliveryDate = res.data.deliveryDate; //交货日期
					this.orderTotalFreight = res.data.orderTotalFreight; //运费
					this.orderBuyRemark = res.data.orderBuyRemark; //备注
					this.orderTotalMoney = res.data.orderTotalMoney; //订单金额
					this.orderPaidMoney = res.data.orderPaidMoney; //已付款
					this.orderConfirmMoney = res.data.orderConfirmMoney; //待确认
					this.orderUnpaidMoney = res.data.orderUnpaidMoney.toFixed(2); //待支付
					this.fundAvailMoney = res.data.fundAvailMoney.toFixed(2); //账户余额

					if(res.data.fundAvailMoney > res.data.orderUnpaidMoney) {
						this.ruleForm.payMoneyOnline = this.orderUnpaidMoney; //可用余额输入框回显
					} else {
						this.ruleForm.payMoneyOnline = this.fundAvailMoney; //可用余额输入框回显
						this.ruleForm.payMoneyOffline = (this.orderUnpaidMoney - this.ruleForm.payMoneyOnline).toFixed(2); //付款金额输入框回显
					}

					this.queryMerChantList(this.orderCode);
				}).catch((err) => {
					this.Public.openError(this, err.response.data);
				});
			},
			//-----------------查询订单和当前资金账户详情---------------------
			queryByPage() {
				this.axios({
					method: 'GET',
					url: "/v3/sale/orders/" + localStorage.getItem("orderCode")
				}).then((res) => {
					var orderGoodsViewVoList = res.data.saleOrderGoodsDataList;
					this.saleOrderViewVo = res.data; // 订单详情
					this.saleOrderGoodsViewVoList = orderGoodsViewVoList; // 订单商品
					if(orderGoodsViewVoList != null && orderGoodsViewVoList != undefined) {
						var valuesum = 0;
						for(var i = 0; i < orderGoodsViewVoList.length; i++) {
							this.invalue += orderGoodsViewVoList[i].goodsBuyNum;
							valuesum += orderGoodsViewVoList[i].goodsBuyNum * orderGoodsViewVoList[i].goodsSalePrice;
						}
						this.valuesum = valuesum.toFixed(2);
					}
					//判断订单状态
					if(res.data.dataBillstate == "3") {
						this.tabxiang = true;
					} else {
						this.tabxiang = false;
					}
					//显示原有物流信息
					if(res.data.dataBillstate == "5" || res.data.dataBillstate == "6") {
						this.saleOrderViewVo.deliveryDate = res.data.deliveryDate;
						this.Fdate = new Date(res.data.deliveryDate);
						this.formLabelAlign.region = res.data.deliveryCompany;
						this.formLabelAlign.type = res.data.deliveryBillNo;
						this.form.desc = res.data.deliveryRemark;
					}
				}).catch((err) => {
					this.Public.openError(this, err.response.data);
				});
			},
			query_systemTemplate() {
				this.axios({
					method: "GET",
					url: "/v3/system/templates/001000000017"
				}).then((res) => {
					this.helpData.templateName = res.data.templateName;
					this.helpData.templateRemark = res.data.templateRemark;
					this.helpData.questionAndAnswerArray = res.data.questionAndAnswerArray;
				}).catch((err) => {
					this.Public.openError(this, err.response.data);
				})
			},
			//出库
			save_out() {
				this.$confirm('是否确认出库？', '出库确认', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					cancelButtonClass: "fr",
					confirmButtonClass: "fr",
				}).then(({
					value
				}) => {

					this.axios({
						method: 'PATCH',
						url: "/v3/sale/orders/" + localStorage.getItem("orderCode") + "/batchOutstockpass",
						data: {}
					}).then((res) => {
						this.Public.openSuccess(this, "操作成功！");
						this.queryOrderAndFud();
						this.queryByPage();
					}).catch((err) => {
						this.Public.openError(this, err.response.data);
					});
				})
			},
			query_checkout() {
				this.axios({
					method: 'GET',
					url: "/v3/sale/orders/" + localStorage.getItem("orderCode"),
					data: {}
				}).then((res) => {
					this.saleOrderGoodsViewVoList2 = res.data.saleOrderGoodsDataList;
				}).catch((err) => {
					this.Public.openError(this, err.response.data);
				});
			},
			//---------------------------详情弹出层  start--------------------------

			goTo(index, data) {
				const h = this.$createElement;
				this.$msgbox({
					title: '订单付款',
					message: h('div', {
						style: 'padding:20px;'
					}, [
						h('p', {
							style: 'line-height:24px;'
						}, [
							h('span', {
								style: 'color:#96a6b6'
							}, '订单号： '),
							h('i', {
								style: 'color: #415161'
							}, data[index].merchantListCode)
						], ),
						h('p', {
							style: 'line-height:24px;'
						}, [
							h('span', {
								style: 'color:#96a6b6'
							}, '金额： '),
							h('i', {
								style: 'color: #415161'
							}, data[index].merchantListMoney)
						], ),
						h('p', {
							style: 'line-height:24px;'
						}, [
							h('span', {
								style: 'color:#96a6b6'
							}, '支付方式：'),
							h('i', {
								style: 'color: #415161'
							}, data[index].merchantPayTypeStr)
						], ),
						h('p', {
							style: 'margin-bottom: 30px;line-height:24px;'
						}, [
							h('span', {
								style: 'color:#96a6b6'
							}, '备注：'),
							h('i', {
								style: 'color: #415161'
							}, data[index].listRemark)
						], ),
						h('p', {
							style: 'line-height:24px;'
						}, [
							h('span', {
								style: 'color:#96a6b6'
							}, '流水号： '),
							h('i', {
								style: 'color: #415161;display: inline-block;width:175px'
							}, data[index].merchantListCode),
							h('span', {
								style: 'color:#96a6b6'
							}, '日期： '),
							h('i', {
								style: 'color: #415161'
							}, data[index].merchantDateStr)
						], )
					], ),
					customClass: "dDFk",
					showCancelButton: true,
					confirmButtonText: '确定',
					showCancelButton: false
				}).then(action => {

				});
			},
			//----------------------作废首款记录----------------------------
			zdelete(index, data) {
				const h = this.$createElement;
				this.$msgbox({
					title: '确认',
					message: h('p', {
						style: 'text-align:center;padding:20px'
					}, [
						h('span', null, '是否作废该笔收款记录？ '),
					]),
					customClass: "Sktan",
					showCancelButton: true,
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					cancelButtonClass: "fr",
					confirmButtonClass: "fr",
				}).then(action => {
					if(action == 'confirm') {
						this.axios({
							method: 'DELETE',
							url: "/v3/fund/merchantLists/" + data[index].merchantListCode,
						}).then((res) => {
							this.axios({
								method: 'post',
								url: "/v3/fund/merchantLists/list",
								data: {
									"limit": this.pageSize,
									"offset": (this.yema - 1) * this.pageSize,
									'orderCode': data[index].merchantListFromCode
								}
							}).then((res) => {
								this.skTableData = res.data.list;
								for(var i = 0; i < this.skTableData.length; i++) {
									this.skTableData[i].merchantListMoney = this.skTableData[i].merchantListMoney.toFixed(2);
								}
								this.recordCount = res.data.page.recordCount; //一共几条数据
								this.pageSize = res.data.page.pageSize; //每页显示多少条
							}).catch((err) => {
								this.Public.openError(this, err.response.data);
							});;
							this.$notify({
								message: '操作成功！',
								type: 'success',
								duration: 3000
							});
						}).catch((err) => {
							this.Public.openError(this, err.response.data);
						});
					}
				}).catch(() => {
					//
				});
			},
			//-----------------批量审核  start---------------------------
			row_batchConfirm(index, data) {
				const h = this.$createElement;
				this.$confirm('确认收款确认？', '确认', {
					message: h('span', {
						style: 'padding:20px;'
					}, "确认收款确认?"),
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					cancelButtonClass: "fr",
					confirmButtonClass: "fr",
					customClass: "clearfixBox"
				}).then(() => {
					//点击确定的回调
					this.axios({
						method: "PATCH",
						url: "/v3/fund/merchantLists/" + data[index].merchantListCode + "/batchConfirm",
						data: {}
					}).then((res) => {
						this.Public.openSuccess(this, "操作成功！");
						this.queryByPage();
					}).catch((err) => {
						this.Public.openError(this, err.response.data)
					});
				}).catch((err) => {
					this.Public.openError(this, err.response.data)
				});
			},
			handleClick(tab, event) {
				console.log(tab, event);
			},
			shenqing(aa) {
				this.disad = !this.disad
			},
			shoukuanMethod() {
				this.axios({
					method: 'PATCH',
					url: "/v3/sale/orders/payment",
					data: {
						"orderUnpaidMoney": this.orderUnpaidMoney, //订单待支付金额
						"fundAvailMoney": this.fundAvailMoney, //会员线上账户可用余额
						"payMoneyOnline": this.ruleForm.payMoneyOnline, //线上支付金额
						"payMoneyOffline": this.ruleForm.payMoneyOffline, //线下支付金额
						"remark": this.ruleForm.remark, //备注
						"merchantListFromCode": this.saleOrderViewVo.orderCode, //订单编号
						"merchantDate": this.ruleForm.merchantDate, //付款时间
						"merchantSignNo": this.ruleForm.merchantSignNo, //收款账号
						"merchantCode":this.ruleForm.merchantCode		//收款账号代码
					}
				}).then((res) => {
					this.$notify({
						message: '操作成功！',
						type: 'success',
						duration: 3000
					});
					this.vue_deliveryRes=true;
					this.shoukuan = false;
					this.queryMerChantList(this.saleOrderViewVo.orderCode);
					this.queryOrderAndFud();
					this.queryMerChantList();
				}).catch((err) => {
					this.Public.openError(this, err.response.data);
				});
			},

			submitForm(formName) {
				this.$refs[formName].validate((valid) => {
					if(valid) {} else {
						return false;
					}
				});
			},
			resetForm(formName) {
				this.$refs[formName].resetFields();
			},

			//添加备注
			addbeizhu() {
				this.$prompt('添加备注', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					cancelButtonClass: "fr",
					confirmButtonClass: "fr",
				}).then(({
					value
				}) => {})
			},
			fpxinxi() {
				if(this.valu == "选项1票") {
					this.putongfp2 = false; //普通发票
					this.zengzhifp = false //增值发票
				}
				if(this.valu == "选项2") {
					this.putongfp2 = true; //普通发票
					this.zengzhifp = false //增值发票
				}
				if(this.valu == "选项3") {
					this.putongfp2 = false; //普通发票
					this.zengzhifp = true //增值发票
				}
			},

			handleChange(file, fileList) {
				this.fileList3 = fileList.slice(-3);
			},
			//---------------------------发货--------------------------------------
			addDeliveryMessage() {
				this.axios({
					method: 'post',
					url: "/v3/sale/orders/updateDelivery",
					data: {
						"orderCode": localStorage.getItem("orderCode"),
						"deliveryDate": this.Fdate,
						"deliveryCompany": this.formLabelAlign.region,
						"deliveryBillNo": this.formLabelAlign.type,
						"deliveryRemark": this.form.desc,
					}
				}).then((res) => {
					if(this.saleOrderViewVo.dataBillstate == "4" || this.saleOrderViewVo.dataBillstate == 4) {
						this.batchConfirmreceipt();
					} else {
						this.Public.openSuccess(this, "操作成功！");
					}
					this.add = false;
					this.queryOrderAndFud();
					this.queryByPage();
					this.vue_deliveryRes=true;
				}).catch((err) => {
					this.Public.openError(this, err.response.data);
				});
			},
			//-----------------------订单发货通过----------------------
			batchConfirmreceipt() {
				this.axios({
					method: 'PATCH',
					url: "/v3/sale/orders/" + localStorage.getItem("orderCode") + "/batchConfirmreceipt",
				}).then((res) => {
					this.Public.openSuccess(this,"操作成功！");
					this.queryOrderAndFud();
					this.queryByPage();
				}).catch((err) => {
					this.Public.openError(this, err.response.data);
				});
			},

			//收款记录列表
			queryMerChantList(orderCode) {
				this.axios({
					method: 'post',
					url: "/v3/fund/merchantLists/list",
					data: {
						"limit": this.pageSize,
						"offset": (this.yema - 1) * this.pageSize,
						"orderCode": orderCode,
					}
				}).then((res) => {
					this.skTableData = res.data.list;
					for(var i = 0; i < this.skTableData.length; i++) {
						this.skTableData[i].merchantListMoney = this.skTableData[i].merchantListMoney.toFixed(2);
					}
					//this.recordCount = res.data.page.recordCount; //一共几条数据
					//this.pageSize = res.data.page.pageSize; //每页显示多少条
				}).catch((err) => {
					this.Public.openError(this, err.response.data);
				});
			},

			// 退回
			retreat() {
				this.$prompt('是否将订单退回 如果确定退回请填写退回原因', '订单退回确认', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					cancelButtonClass: "fr",
					confirmButtonClass: "fr",
				}).then(({
					value
				}) => {
					this.axios({
						method: 'PATCH',
						url: "/v3/sale/orders/" + this.saleOrderViewVo.orderCode + "/batchRetreat",
					}).then((res) => {
						this.$notify({
							message: '操作成功！',
							type: 'success',
							duration: 3000
						});
						this.$router.push({
							path: "/order"
						});
					}).catch((err) => {
						this.Public.openError(this, err.response.data);
					});
				})
			},
			// 审核通过
			auditpass() {
				this.$confirm('是否将订单审核通过', '订单审核通过确认', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					cancelButtonClass: "fr",
					confirmButtonClass: "fr",
				}).then(({
					value
				}) => {
					this.axios({
						method: 'PATCH',
						url: "/v3/sale/orders/" + this.saleOrderViewVo.orderCode + "/batchAuditpass",
					}).then((res) => {
						this.$notify({
							message: '操作成功！',
							type: 'success',
							duration: 3000
						});
						this.$router.push({
							path: "/order"
						});
					}).catch((err) => {
						this.Public.openError(this, err.response.data);
					});
				})
			},

			// 修改订单
			update() {
				this.Public.setCookie("orderCode", this.saleOrderViewVo.orderCode, 1);
				this.$router.push({
					path: "/Modiforder"
				})
			},
		},

		// 修改

	}
</script>

<style scoped>
	@import "../../../assets/css/zijin.css";
	.location {
		padding: 3px 0 15px 0;
	}

	.order {
		background: #fff;
		padding: 5px 20px;
		overflow-y: auto;
		font-family: "微软雅黑";
		position: relative;
	}

	.order-input-em2 {
		position: relative;
		right: 5px;
		top: 0px;
		cursor: pointer;
	}

	.order-tab {
		margin-top: 15px;
		border-left: 1px solid #e7e9f1;
	}

	.order-tab1 td {
		text-align: center;
		padding: 0px 0;
		border: 1px solid #e7e9f1;
		border-top: 0;
		border-left: 0;
		position: relative;
	}

	.order-tab1 td img {
		width: 45px;
		margin: 0 auto;
	}

	.order-tab1 .tab-th td {
		background: #eff1f8;
		padding: 14px 0;
	}

	.order-tab1 .order-input1 {
		height: 34px;
		width: 100px;
		border: 1px solid #cdd9e6;
		border-radius: 4px;
		text-indent: 5px;
	}

	.dorder-td td {
		padding: 15px 0;
	}

	.dorder-tend td {
		padding: 12px 15px;
		text-align: right;
	}

	.activedis {
		background: #eff1f8;
		cursor: no-drop;
	}

	.dorder-tend p span {
		display: inline-block;
		width: 120px;
	}

	.dorder-tend p:last-child span {
		color: #f33333;
		font-size: 20px;
	}

	.dorder-tend p {
		margin-top: 0px;
	}

	.order-xinxi {
		margin: 20px;
		margin-bottom: 50px;
	}

	.order-deta {
		position: relative;
		margin-top: 15px;
		clear: both;
		overflow: hidden;
	}

	.order-deta span {
		margin-right: 10px;
	}

	.order-deta a {
		display: inline-block;
		width: 80px;
		height: 30px;
		text-align: center;
		line-height: 31px;
		border-radius: 20px;
		border: 1px solid #cdd9e6;
		margin-top: 30px;
	}

	.order-deta a:first-child {
		background: rgb(19, 193, 159);
		color: #fff;
		border: 0;
		height: 32px;
		line-height: 32px;
	}

	.putongfp {
		margin-left: 62px;
	}

	.order-caozuo {
		position: absolute;
		top: 10px;
		right: 20px;
		z-index: 100;
		color: #7d91a5;
		margin-right: 20px;
	}

	.order-caozuo span {
		margin-left: 15px;
		cursor: pointer!important;
		display: inline-block;
	}

	.order-caozuo span a {
		color: #7d91a5;
	}

	.order-caozuo span a:hover {
		color: #13C19F;
	}

	.order-caozuo span em {
		position: relative;
		top: 2px;
	}

	.order-caozuo span:hover {
		color: #13C19F;
	}

	.order-select {
		overflow: hidden;
		position: relative;
	}

	.order-select h2 {
		color: #f96b6b;
		font-weight: normal;
		margin-top: 15px;
		float: left;
	}

	.order-select p {
		margin-top: 20px;
		float: left;
	}

	.order-select .select-span {
		margin-left: 20px;
	}

	.order-redio {
		float: right;
		margin-top: 20px;
	}

	.huise {
		color: #98a8b8;
		display: inline-block;
		margin-right: 20px;
		text-align: right;
	}

	.order-czrz {
		width: 100%;
		margin-top: 20px;
	}

	.order-czrz th {
		font-weight: normal;
		text-align: left;
		background: #eff1f8;
		border: 1px solid #cdd9e6;
		border-top: 0;
		border-left: 0;
		height: 40px;
		text-indent: 15px;
		font-size: 13px;
	}

	.order-czrz td {
		text-indent: 15px;
		height: 40px;
	}

	.bzstyle {
		border: 1px solid #cdd9e6;
		width: 375px;
		height: 150px;
		margin: 0 auto;
		border-radius: 3px;
	}

	.ckfhjl-top {
		padding: 20px 25px;
		background: #fff9ef;
		margin: 15px 0;
		overflow: hidden;
	}

	.ckfhjl-top-span {
		font-size: 18px;
		color: #f96b6b;
		font-weight: normal;
	}

	.ckfhjl-top p {
		line-height: 30px;
	}

	.ckfhjl-top span {
		margin-right: 20px;
	}

	.chuku-top {
		height: 31px;
		width: 150px;
		text-align: center;
		cursor: pointer;
		line-height: 29px;
		margin: 10px 0;
	}

	.chukuactive {
		border-bottom-right-radius: 20px;
		border-top-right-radius: 20px;
		background: #93a6b7;
		color: #fff;
	}

	.chuku-top em {
		position: relative;
		top: 1px;
	}

	.chuku-table {
		border: 1px solid #cdd9e6;
		position: relative;
	}

	.chuku-two {
		border-top: 1px solid #cdd9e6;
		text-align: right;
		padding: 15px;
	}

	.chuku-two span {
		margin-left: 15px;
	}

	.chuku-two span:hover {
		color: #13C19F;
		cursor: pointer;
	}

	.table-bottom {
		padding: 15px;
	}

	.table-bottom p {
		line-height: 22px;
	}

	.table-bottom span {
		color: #98a8b8;
		display: inline-block;
		width: 70px;
	}

	.shoukuan-table {
		margin-top: 20px;
		border-left: 1px solid rgb(223, 234, 236);
	}

	.addSk {
		position: absolute;
		width: 100px;
		height: 32px;
		line-height: 32px;
		color: #fff;
		background: #13C19F;
		border-radius: 20px;
		text-align: center;
		right: 0;
		bottom: 0px;
		cursor: pointer;
	}

	.tejia {
		color: #fff;
		background: #FF0000;
		margin-left: 3px;
	}

	.fade-enter-active,
	.fade-leave-active {
		transition: .4s;
	}

	.fade-enter,
	.fade-leave-active {
		opacity: 0;
	}

	.slideDown-enter-active,
	.slideDown-leave-active {
		transition: .4s;
	}

	.add {
		position: absolute;
		padding: 10px 20px 20px 20px;
		z-index: 100;
		background: #fff;
		width: 100%;
		box-shadow: 0px 0px 5px #666;
		top: 0;
		left: 0;
		box-sizing: border-box;
	}

	.Fblock {
		margin-top: 20px;
		margin-left: 20px;
		margin-bottom: 22px;
	}

	.Fblock .demonstration {
		margin-right: 8px;
	}

	.search-btn {
		margin-top: 20px;
		clear: both;
	}

	.el-date-editor.el-input {
		width: 320px;
	}

	.wuliB {
		float: left;
		width: 480px;
		margin-top: 18px;
	}

	.wuliB .el-textarea__inner {
		height: 100px;
	}

	.el-col-11 {
		width: 300px;
	}

	.el-select {
		width: 300px;
	}

	.daizhifu {
		box-sizing: border-box;
		margin-left: 25px;
		padding: 15px;
		background: #f8f9fd;
		margin-top: 20px;
	}

	.daizhifu p {
		border-bottom: 1px solid #cdd9e6;
		line-height: 35px;
		margin-bottom: 5px;
	}

	.daizhifu>span {
		font-size: 22px;
		color: #f96b6b;
	}

	.daizhifu>span span {
		position: relative;
		top: 3px;
		margin-left: 5px;
	}

	.daizhifu i span {
		margin: 0 10px;
	}

	.el-date-editor.el-input {
		width: 180px;
	}

	.upload-demo {
		margin-left: 100px;
	}

	.caozuoqizhi {
		cursor: pointer;
	}

	.caozuoqizhi em {
		font-size: 12px;
		margin-left: 2px;
		display: inline-block;
	}

	.activEm {
		-webkit-transform: rotateX(180deg);
		transform: rotateX(180deg);
	}

	.p:hover {
		background: #EEF1F9;
		color: #03b8cc;
	}

	.p {
		text-indent: 10px;
	}

	.benciCk input {
		height: 34px;
		width: 80px;
		border: 1px solid #cdd9e6;
		border-radius: 4px;
		text-indent: 5px;
		margin-right: 3px;
	}

	.order-select p {
		margin-right: 20px;
	}

	.chuku-em {
		top: -1px!important;
	}

	.chuku-two-a {
		display: inline-block;
		height: 32px;
		color: #FFF;
		background: #13C19F;
		width: 80px;
		text-align: center;
		line-height: 32px;
		border-radius: 20px;
	}

	.add h3 {
		font-size: 16px;
		font-weight: normal;
	}

	.name-wrapper img {
		width: 42px;
		margin: 0 auto;
	}

	.outpass {
		display: inline-block;
		width: 80px;
		box-sizing: border-box;
		height: 32px;
		line-height: 32px;
		text-align: center;
		background: #13C19F;
		color: #fff;
		border-radius: 20px;
	}

	.order-caozuo .outpass:hover {
		color: #fff;
	}
	.el-upload__tip{
		width:286px;
		height:34px;
		margin-top:0;
		margin-left:7px;
	}
</style>
